package chixing.day11.class1;

public class Book {
    private int bookId;
    private String bookName;
    private float bookPrice;
    public Book(){}
    public Book(String bookName,float bookPrice){
        this.bookName=bookName;
        this.bookPrice=bookPrice;
    }
    public Book(int bookId,String bookName,float bookPrice){
        this.bookId=bookId;
        this.bookName=bookName;
        this.bookPrice=bookPrice;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Book newBook = new Book();
        newBook.bookId=this.bookId;
        newBook.bookName=this.bookName;
        newBook.bookPrice=this.bookPrice;
        return newBook;
    }

    /**
     * clone object
     * 1 new instance Book newBook = new Book();
     * 2 copy filed value
     * 浅克隆
     * 克隆的属性 是基本数据类型+String
     * @return
     */

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public float getBookPrice() {
        return bookPrice;
    }

    public void setBookPrice(float bookPrice) {
        this.bookPrice = bookPrice;
    }

    public int getBookId() {
        return bookId;
    }

    public void setBookId(int bookId) {
        this.bookId = bookId;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookName='" + bookName + '\'' +
                ", bookPrice=" + bookPrice +
                '}';
    }
}
